<?php
namespace Modules\Common\Controllers;

class RegionController extends \Phalcon\Mvc\Controller {
  public function indexAction() {
    $mode = $this -> request -> getQuery('mode', 'int', 1, true);
    if(!in_array($mode, [1, 2])) {
      $mode = 1;
    }

    $getRegion = $this -> backendCache -> get('region' . $mode);

    if(!$getRegion) {
      $getRegion = (new \Modules\Common\Services\SysRegionService()) -> getList($mode);
      $this -> backendCache -> save('region' . $mode, $getRegion);
    }

    return $this -> response -> setContentType('application/json', 'UTF-8') -> setJsonContent($getRegion);
  }
}
?>